package Day23;
import java.util.*;

public class A1 {


    public static void main(String[] args) {
        Scanner in = new Scanner(System.in);
        // 注意 hasNext 和 hasNextLine 的区别
        while (in.hasNextInt()) { // 注意 while 处理多个 case
            int t = in.nextInt();
            int[][] nums = new int[t][4];
            for(int i=0;i<t;i++) {
                nums[i][0] = in.nextInt();
                nums[i][1] = in.nextInt();
                nums[i][2] = in.nextInt();
                nums[i][3] = in.nextInt();
            }
            int k=0;
            while(k<t) {
                int h = nums[k][0],a = nums[k][1],H = nums[k][2], A = nums[k][3];
                int ret=0,x=H;
                if(a>=H) {
                    ret=-1;
                }else {
                    while(h>0) {
                        H -= a;
                        if(H<=0) {
                            ret++;
                            H=x; //继续下一个怪物
                            continue;
                        }
                        h -= A;
                    }
                }
                System.out.println(ret);
                k++;
            }
        }
    }
}
